package com.example.rocketmqspringbootdemo.service.consumer;

import com.example.rocketmqspringbootdemo.CommonConstrant;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQReplyListener;
import org.springframework.stereotype.Service;
import java.time.LocalTime;

@Service
@RocketMQMessageListener(topic = CommonConstrant.RocketMQ.STRING_TOPIC_REPLY,
        consumerGroup = CommonConstrant.RocketMQ.STRING_CONSUMER_REPLY_GROUP1,
        messageModel = MessageModel.CLUSTERING,
        selectorType = SelectorType.TAG,
        selectorExpression = "TagString",
        replyTimeout = 5000)
public class StringConsumerWithReplyString implements RocketMQReplyListener<String, String> {
    @Override
    public String onMessage(String message) {
        System.out.printf("[STRING_TOPIC_REPLY]received: %s \n", message);
        return "reply string----"+ LocalTime.now();
    }
}
